package com.bph.commons.utils;

import com.bph.commons.pojo.User;
import java.util.ArrayList;

public class SP {
    /**
     * 解析字符串
     * @param str
     * @return
     */
    public static String[] str_Parse(String str){
        String[] s = {};
        if(str.contains(";")){
            String tmp = str.replaceFirst(";",",");
            s = SP.str_Parse(tmp);
        }else{
            s = str.split(",");
        }
        return s;
    }

    //测试代码
    public static void main(String[] args) {
//        System.out.println(SP.str_Parse("1,3;2,5")[1]);

        ArrayList<User> users = new ArrayList<>();
        User user1 = new User();
        user1.setUser_name("张三");
        User user2 = new User();
        user2.setUser_name("李四");
        users.add(user1);
        users.add(user2);
        System.out.println(users);
    }

}
